/*
 * TCSS 360 - Autumn 2011
 * Group2: ManuscriptPR 
 * 
 * Conference class
 * Author: Tony Butterfield
 */
package user;

import java.util.Calendar;
import java.util.Locale;

/**
 * contains conference data.
 * @author Tony Butterfield
 * @version 11/29/2011
 */
public class Conference 
{
  // INSTANCE VARIABLES ***********************************
  /** conference name. */
  private String my_conference_name;
  
  /** conference date. */
  private Calendar my_conference_date;
  
  /** deadline for manuscript submissions. */
  private Calendar my_conference_deadline;
  
  /** flag to indicate that all decisions have been made and are available for view. */
  private boolean my_publish_status;
  
  
  // CONSTRUCTORS *****************************************
  /**
   * constructs an instance of a Conference, throws NullPointerException if any param is null,
   * throws IllegalArgumentException is the deadline is after the conference date.
   * @param the_conference_name String containing the name of the conference
   * @param the_conference_date Calendar containing the date of the conference
   * @param the_conference_deadline Calendar containing the deadline for manuscript 
   *  submissions to the conference
   * ******************************************************
   * @requires
   *  the_conference_name = non-empty String
   *  the_conference_date = Calendar && != null
   *  the_conference_deadline = Calendar && != null
   *  the_conference_deadline <= the_conference_date
   * @ensures a Conference object with the given attributes.
   */
  public Conference(final String the_conference_name, final Calendar the_conference_date, 
                    final Calendar the_conference_deadline)
  {    
    if (the_conference_name == null || the_conference_date == null || 
        the_conference_deadline == null)
    {
      throw new NullPointerException();      
    }
    
    if (the_conference_deadline.after(the_conference_date))
    {
      throw new IllegalArgumentException();
    }

    setConferenceName(the_conference_name);
    setConferenceDate(the_conference_date);
    setConferenceDeadline(the_conference_deadline);
    setPublishStatus(false);    
  }
  
  
  // ACCESSORS ********************************************
  /**
   * get conference name.
   * @return String containing conference name
   */
  public String getConferenceName()
  {
    return my_conference_name;    
  }
  
  /**
   * get conference start date.
   * @return Calendar containing the start date
   */
  public Calendar getConferenceDate()
  {
    return my_conference_date;    
  }
  
  /**
   * get conference deadline for manuscript submissions.
   * @return Calendar containing deadline date.
   */
  public Calendar getConferenceDeadline()
  {
    return my_conference_deadline;    
  }
  
  /**
   * get the status of the decision to publish the results.
   * @return boolean permission to publish results
   */
  public boolean getPublishStatus()
  {
    return my_publish_status;
  }
  
  
  // MUTATORS *********************************************
  /**
   * sets the conference name.
   * @param the_conference_name String containing the name
   */
  private void setConferenceName(final String the_conference_name)
  {
    my_conference_name = the_conference_name;
  }
  
  /**
   * sets the conference start date.
   * @param the_conference_date Calendar containing the start date of the conference
   */
  private void setConferenceDate(final Calendar the_conference_date)
  {
    my_conference_date = the_conference_date;
  }
  
  /**
   * sets the conference deadline for manuscript submissions.
   * @param the_conference_deadline Calendar containing the submission deadline.
   */
  private void setConferenceDeadline(final Calendar the_conference_deadline)
  {
    my_conference_deadline = the_conference_deadline;
  }
  
  /**
   * sets a flag that indicates that the decisions on all manuscripts are ready to be 
   * published.  
   * @param the_status boolean that indicates the status: FALSE = not published
   *                                                      TRUE = published
   */
  private void setPublishStatus(final boolean the_status)
  {
    my_publish_status = the_status;    
  }

  
  // METHODS **********************************************
  /**
   * toString method.
   * @return String representation of a Conference object
   */
  public String toString()
  {
    final StringBuilder s = new StringBuilder();
    
    s.append(getConferenceName());
    s.append(" (");
    s.append(getConferenceDate().getDisplayName(Calendar.MONTH, Calendar.SHORT, Locale.US));
    s.append(" ");
    s.append(getConferenceDate().get(Calendar.YEAR));
    s.append(")");
    
    return s.toString();
  }

  
  
}
